#include <iostream>

class Test {
public:
    Test(int) { std::cout<< "Test(int)"<< std::endl; }
    Test(const Test&) { std::cout<< "Test(const Test&)"<< std::endl; }
    Test(Test&&) { std::cout<< "Test(Test&&)"<< std::endl; }
};

Test GetTest()
{
    return Test(1);
}

void GetTest(Test& t) {
    new(&t) Test(1);
}

Test GetTest1()
{
    Test t = Test(1);
    //t.set...
    return t;
}

void GetTest1(Test& t) {
    new(&t) Test(1);
    //t.set...
}

Test GetTest2(bool flag) {
    Test t(1), t1(2);
    //t.set...
    //t1.set...

    if (flag)
        return t;
    
    return t1;
}

Test tGlobal(1);
Test GetTest3() {
    return tGlobal;
}

Test GetTest4(Test& t) {
    return t;
}

int main() {
    Test t = GetTest();
    std::cout << "==========" << std::endl;
    {
        char buf[sizeof(Test)];
        GetTest(*reinterpret_cast<Test*>(buf));
    }

    std::cout << "==========" << std::endl;
    {
        auto t1 = GetTest1();
    }

    std::cout << "==========" << std::endl;
    {
        auto t2 = GetTest2(false);
    }
    return 0;
}